package mysql

import "gorm.io/gorm"

type Users struct {
	gorm.Model
	Phone     string `gorm:"type:char(11);not null;comment:手机号"`
	Password  string `gorm:"type:varchar(32);not null;comment:密码"`
	UserState int    `gorm:"type:int(10);not null;comment:用户状态"`
}

func (u *Users) Where(phone string) error {
	return DB.Debug().Where("phone=?", phone).Limit(1).Find(&u).Error
}
func (u *Users) UserList(UserState int) (list []*Users, err error) {
	err = DB.Where("user_state=?", UserState).Find(&list).Error
	return
}
func (g *Users) UpdateUser(userID, userState int) error {
	return DB.Model(&Users{}).Where("id= ? ", userID).Update("user_state", userState).Error
}
